#include "mex.h"
double add(double x,double y)
{
    return x+y;
}
void hilb(double *y, int n)
{
    int i j;
    for(i=0;i<n;i++)    
        for(j=0;j<n;j++)
        {
            *(y+j+i*(n))=((double)j+(double)i+1);
        }
}
void mexFunction ( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
    double *M,*A,x;
    int m,n;
    
    if (nrhs!=1)
        mexErrMsgTxt("One inputs required.");
    if (nlhs != 1)
        mexErrMsgTxt("One output required.");
    if (!mxIsDouble(prhs[0])||mxGetN(prhs[0])*mxGetM(prhs[0])!=1)
        mexErrMsgTxt("Input must be scalars.");

    x=mxGetScalar(prhs[0]);
    
    plhs[0] = mxCreateDoubleMatrix(x,x,mxREAL);
    
    A=mxGetPr(plhs[0]);
    hilb(A,x);

}